import { Config, Provide } from '@midwayjs/decorator';
import * as JsonWebToken from 'jsonwebtoken';
const md5 = require('md5');
@Provide()
export default abstract class BaseServices {
  @Config('jwt')
  jwt;

  md5(str) {
    return md5(str);
  }

  jwtSign(sign: any, options?: any): string {
    return JsonWebToken.sign(sign, this.jwt.secret, options);
  }

  jwtVerify(token: string, options?: any): any {
    return JsonWebToken.verify(token, this.jwt.secret, options);
  }
}
